package xyz.xuminghai.javafx_learn.other;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

/**
 * 2023/10/27 14:00 星期五<br/>
 *
 * @author xuMingHai
 */
public class TestApp extends Application {

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle(getClass().getSimpleName());

        Button button1 = new Button("button1");
        Button button2 = new Button("button2");

        Scene scene1 = new Scene(new BorderPane(button1), 800.0, 600.0);
        Scene scene2 = new Scene(new BorderPane(button2), 800.0, 600.0);

        button1.setOnAction(event -> {
            primaryStage.setScene(scene2);
            System.out.println("scene2.getWidth() = " + scene2.getWidth());
        });
        button2.setOnAction(event -> primaryStage.setScene(scene1));

        primaryStage.setScene(scene1);
        primaryStage.show();

    }
}
